<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    window.navigator.geolocation.getCurrentPosition(success,error);
    function success(){
      alert('获取到地理位置')
    }
    function error(){
      alert('没有获取到地理位置')；
    }
  </script>
</body>
</html> -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    window.navigator.geolocation.getCurrentPosition(success,error);
    function success(position){
      alert('纬度'+position.coords.latitude,'经度'+position.coords.longitude);
    }
    function error(msg){
      alert(msg)
    }
  </script>
</body>
</html>